﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VK.Casemeet.Employees;
using VK.Comm;

namespace VK.Casemeet.Web.Admin.Employees
{
    public partial class EmployeePass : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lbAccount.Text = EmployeeService.GetSessionEmployee().Account;
        }

        protected void butSave_Click(object sender, EventArgs e)
        {
            string strMessage = "";
            if (txtOldPass.Text.Length == 0)
            {
                strMessage += "----原密码不能为空!\\n";
            }
            if (txtNewPass.Text.Length == 0)
            {
                strMessage += "----新密码不能为空!\\n";
            }
            if (txtCheckPass.Text != txtNewPass.Text)
            {
                strMessage += "----两次输入密码要相同!\\n";
            }
            if (strMessage.Length != 0)
            {
                Message.Msg(this.Page, strMessage, MessageType.Normal);
                return;
            }

            if (EmployeeBLL.UpdateEmployeePass(
                EmployeeService.GetSessionEmployee().EmployeeID,
                DES.Encrypt(txtOldPass.Text, CS.AdminPassKey),
                DES.Encrypt(txtNewPass.Text, CS.AdminPassKey)) == 1)
            {
                Message.Msg(this.Page, CS.MsgEditSuccess, MessageType.Success);
            }
            else
            {
                Message.Msg(this.Page, CS.MsgEditFailure, MessageType.Failure);
            }
        }
    }
}